home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / dcopref.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  54.7 KB  |  1,475 lines

  1. /*
  2. Copyright (c) 2002 Matthias Ettrich <ettrich@kde.org>
  3. Copyright (c) 1999 Preston Brown <pbrown@kde.org>
  4.  
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11.  
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14.  
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  18. AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  19. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22.  
  23. #ifndef _DCOPREF_H
  24. #define _DCOPREF_H
  25.  
  26. #include <qcstring.h>
  27. #include <dcoptypes.h>
  28. #include <kdatastream.h> // needed for proper bool marshalling
  29. #include "kdelibs_export.h"
  30.  
  31. class QDataStream;
  32. class DCOPObject;
  33. class DCOPClient;
  34.  
  35. /**
  36.  * Represents the return value of a DCOPRef:call() or
  37.  * DCOPRef:send() invocation.
  38.  *
  39.  * @see DCOPRef
  40.  * @see DCOPRef::call()
  41.  * @see DCOPArg
  42.  * @since 3.1
  43.  */
  44. class DCOP_EXPORT DCOPReply
  45. {
  46. public:
  47.   /**
  48.    * Casts the value to the type @p T. Requires that the
  49.    * type @p T suppports QDataStream deserialisation
  50.    * and has a function dcopTypeName(T). This is true for most
  51.    * basic types.
  52.    */
  53.     template<class T>
  54.     operator T() {
  55.     T t;
  56.     dcopTypeInit(t);
  57.     if ( typeCheck( dcopTypeName(t), true ) ) {
  58.         QDataStream reply( data, IO_ReadOnly );
  59.         reply >> t;
  60.     }
  61.     return t;
  62.     }
  63.   /**
  64.    * Retrieves the value from the type @p T. Requires that the
  65.    * type @p T suppports QDataStream deserialisation.
  66.    * @param t the type will be written here, if successful
  67.    * @param tname the signature type name
  68.    * @return true if successful, false otherwise
  69.    */
  70.     template <class T> bool get(  T& t, const char* tname ) {
  71.     if ( typeCheck( tname, false ) ) {
  72.         QDataStream reply( data, IO_ReadOnly );
  73.         reply >> t;
  74.         return true;
  75.     }
  76.     return false;
  77.     }
  78.   /**
  79.    * Retrieves the value from the type @p T. Requires that the
  80.    * type @p T suppports QDataStream deserialisation
  81.    * and has a function dcopTypeName(T). This is true for most
  82.    * basic types.
  83.    * @param t the type will be written here, if successful
  84.    * @return true if successful, false otherwise
  85.    */
  86.     template <class T> bool get(  T& t ) {
  87.     if ( typeCheck( dcopTypeName(t), false ) ) {
  88.         QDataStream reply( data, IO_ReadOnly );
  89.         reply >> t;
  90.         return true;
  91.     }
  92.     return false;
  93.     }
  94.  
  95.     /**
  96.      * Checks whether the type is valid.
  97.      * @return true if valid, false otherwise
  98.      */
  99.     inline bool isValid() const { return !type.isNull(); }
  100.  
  101.     /// The serialized data.
  102.     QByteArray data;
  103.     /// The name of the type, or 0 if unknown.
  104.     QCString type;
  105. private:
  106.     bool typeCheck( const char* t );
  107.     bool typeCheck( const char* t, bool warn );
  108. };
  109.  
  110. /**
  111.  * A generic DCOP argument.
  112.  * This class allows you to use user-defined argument types for
  113.  * DCOPRef::call() or DCOPRef::send().
  114.  *
  115.  * @see DCOPRef::call()
  116.  * @see DCOPRef
  117.  * @see DCOPReply
  118.  * @since 3.1
  119.  */
  120. class DCOP_EXPORT DCOPArg  {
  121. public:
  122.     /**
  123.      * Creates a DCOPArg for DCOPRef::call().
  124.      * @param t the data that will be written to a QDataStream. It must
  125.      *          overload writing to a QDataStream using the "<<"
  126.      *          operator
  127.      * @param tname_arg the name of the data that will appear in the
  128.      *        function's signature
  129.      */
  130.     template <class T> DCOPArg( const T& t, const char* tname_arg )
  131.     : tname(tname_arg)
  132.     {
  133.         QDataStream ds( data, IO_WriteOnly );
  134.         ds << t;
  135.     }
  136.     /**
  137.      * Creates a DCOPArg for DCOPRef::call().
  138.      * @param t the data that will be written to a QDataStream. It must
  139.      *          overload writing to a QDataStream using the "<<"
  140.      *          operator. The name of the type will be determined by
  141.      *          calling the function dcopTypeName(T) that must be provided
  142.      *          by you.
  143.      */
  144.     template <class T> DCOPArg( const T& t )
  145.     : tname( dcopTypeName(t) )
  146.     {
  147.         QDataStream ds( data, IO_WriteOnly );
  148.         ds << t;
  149.     }
  150.  
  151.     /// The serialized data.
  152.     QByteArray data;
  153.     /// The signature type name of the data.
  154.     const char* tname;
  155. };
  156.  
  157. inline const char* dcopTypeName( const DCOPArg &arg )  { return arg.tname; }
  158. inline QDataStream & operator << (QDataStream & str, const DCOPArg& arg )
  159.    { str.writeRawBytes( arg.data.data(), arg.data.size() ); return str; }
  160.  
  161.  
  162.  
  163. /**
  164.  * A DCOPRef(erence) encapsulates a remote DCOP object as a triple
  165.  * <app,obj,type> where type is optional. It allows for calling and
  166.  * passing DCOP objects.
  167.  *
  168.  * A DCOP reference makes it possible to return references to other DCOP
  169.  * objects in a DCOP interface, for example in the method
  170.  * giveMeAnotherObject() in an interface like this:
  171.  *
  172.  * \code
  173.  *    class Example : public DCOPObject
  174.  *    {
  175.  *       K_DCOP
  176.  *    ...
  177.  *    k_dcop:
  178.  *       DCOPRef giveMeAnotherObject();
  179.  *       int doSomething( QString, float, bool );
  180.  *       ASYNC pingMe( QCString message );
  181.  *       UserType userFunction( UserType );
  182.  *    };
  183.  * \endcode
  184.  *
  185.  * In addition, the reference can operate as a comfortable generic
  186.  * stub to call remote DCOP objects in cases where no DCOPStub is
  187.  * available. The advantage of using DCOPRef instead of the low-level
  188.  * functions DCOPClient::call() and DCOPClient::send() are the nicer
  189.  * syntax and the implicit runtime error checking.
  190.  *
  191.  * Say you want to call the method "doSomething" from the above
  192.  * interface on an object called "example" that lives in application
  193.  * "foo". Using DCOPRef, you would write
  194.  *
  195.  * \code
  196.  *    DCOPRef example( "foo", "example" );
  197.  *    int result = example.call( "doSomething", QString("Hello World"), (float)2.5, true );
  198.  * \endcode
  199.  *
  200.  * If it is important for you to know whether the call succeeded or
  201.  * not, you can use the slightly more elaborate pattern:
  202.  *
  203.  * \code
  204.  *    DCOPRef example( "foo", "example" );
  205.  *    DCOPReply reply = example.call( "doSomething", QString("Hello World"), (float)2.5, true );
  206.  *    if ( reply.isValid() ) {
  207.  *        int result = reply;
  208.  *        // ...
  209.  *    }
  210.  * \endcode
  211.  *
  212.  * Note that you must pass a QString for the first argument. If you use a
  213.  * regular char pointer, it will be converted to a QCString.
  214.  *
  215.  * For curiosity, here is how you would achieve the exactly same
  216.  * functionality by using DCOPClient::call() directly:
  217.  *
  218.  * \code
  219.  *    QByteArray data, replyData;
  220.  *    QCString replyType;
  221.  *    QDataStream arg( data, IO_WriteOnly );
  222.  *    arg << QString("hello world" ), (float) 2.5 << true;
  223.  *    if ( DCOPClient::mainClient()->call( app, obj,
  224.  *                 "doSomething(QString,float,bool)",
  225.  *                 data, replyType, replyData ) ) {
  226.  *    if ( replyType == "int" ) {
  227.  *        int result;
  228.  *        QDataStream reply( replyData, IO_ReadOnly );
  229.  *        reply >> result;
  230.  *        // ...
  231.  *    }
  232.  *    }
  233.  * \endcode
  234.  *
  235.  * As you might see from the code snippet, the DCOPRef has to "guess"
  236.  * the names of the datatypes of the arguments to construct a dcop
  237.  * call. This is done through global inline overloads of the
  238.  * dcopTypeName function, for example
  239.  *
  240.  * \code
  241.  *    inline const char* dcopTypeName( const QString& ) { return "QString"; }
  242.  * \endcode
  243.  *
  244.  * If you use custom data types that do support QDataStream but have
  245.  * no corresponding dcopTypeName overload, you can either provide such
  246.  * an overload or use a DCOPArg wrapper that allows you to specify the type.
  247.  *
  248.  * \code
  249.  *    UserType userType;
  250.  *    DCOPReply reply = example.call( "userFunction", DCOPArg( userType, "UserType" ) );
  251.  * \endcode
  252.  *
  253.  * Similar, when you retrieve such a data type, you can use an
  254.  * explicit call to DCOPReply::get():
  255.  *
  256.  * \code
  257.  *    UserType userType;
  258.  *    reply.get( userType, "UserType" );
  259.  * \endcode
  260.  *
  261.  * The function send() works very similar to call(), only that it
  262.  * returns a simple bool on whether the signal could be sent or not:
  263.  *
  264.  * \code
  265.  *    if ( example.send( "pingMe", "message" ) == false )
  266.  *       qWarning("could not ping example" );
  267.  * \endcode
  268.  *
  269.  * A DCOP reference operates on DCOPClient::mainClient(), unless you
  270.  * explicitly specify another client with setDCOPClient().
  271.  *
  272.  * @see DCOPArg
  273.  * @see DCOPReply
  274.  * @see DCOPObject
  275.  * @author Matthias Ettrich <ettrich@kde.org>, Torben Weis <weis@kde.org>
  276.  */
  277.  
  278. class DCOP_EXPORT DCOPRef
  279. {
  280. public:
  281.     /**
  282.      * Creates a null reference.
  283.      * @see isNull()
  284.      */
  285.     DCOPRef();
  286.  
  287.     /**
  288.      * Copy constructor.
  289.      */
  290.     DCOPRef( const DCOPRef& ref );
  291.     /**
  292.      *  Creates a reference for application @p app and object @p obj
  293.      *
  294.      * @param app The name of an application as registered
  295.      *            by the dcopserver.
  296.      * @param obj The name of the dcop object.
  297.      */
  298.     DCOPRef( const QCString& app, const QCString& obj = "" );
  299.  
  300.     /**
  301.      * Creates a reference to an existing dcop object
  302.      *
  303.      * @param object The dcop object to create the ref to.
  304.      */
  305.     DCOPRef( DCOPObject *object );
  306.  
  307.     /**
  308.      *  Creates a reference for application @p app and object @p obj
  309.      * with a specified type @p type.
  310.      *
  311.      * @param app The name of an application as registered
  312.      *            by the dcopserver.
  313.      * @param obj The name of the dcop object
  314.      * @param type The object's type
  315.      */
  316.     DCOPRef( const QCString& app, const QCString& obj, const QCString& type );
  317.  
  318.     /**
  319.      * Tests whether this is a null reference.
  320.      * @return true if this object is a null reference
  321.      * @see clear()
  322.      */
  323.     bool isNull() const;
  324.  
  325.     /**
  326.      * Name of the application in which the object resides.
  327.      * @return the application's id. Can be null or empty if not set.
  328.      */
  329.     QCString app() const;
  330.  
  331.     /**
  332.      * Object ID of the referenced object.
  333.      * @return the id of the referenced object. Can be null or empty if not set.
  334.      * @since 3.1
  335.      */
  336.     QCString obj() const;
  337.  
  338.     /**
  339.      * @obsolete
  340.      */
  341.     QCString object() const;
  342.  
  343.     /**
  344.      * Type of the referenced object. May be null (i.e. unknown).
  345.      * @return the type of the referenced object, or null if unknown
  346.      */
  347.     QCString type() const;
  348.  
  349.  
  350.     /**
  351.      * Assignment operator. Copies the references data.
  352.      */
  353.     DCOPRef& operator=( const DCOPRef& );
  354.  
  355.     /**
  356.      * Changes the referenced object. Resets the type to unknown (null).
  357.      * The type is not needed for call() and send().
  358.      * @param app the application id.
  359.      * @param obj the object id
  360.      */
  361.     void setRef( const QCString& app, const QCString& obj = "" );
  362.  
  363.     /**
  364.      * Changes the referenced object.
  365.      * @param app the application id.
  366.      * @param obj the object id
  367.      * @param type the object's type
  368.      */
  369.     void setRef( const QCString& app, const QCString& obj, const QCString& type );
  370.  
  371.  
  372.     /**
  373.      * Makes this a null reference.
  374.      * @see isNull()
  375.      */
  376.     void clear();
  377.  
  378.  
  379.     /**
  380.      * Returns the dcop client the reference operates on. If no client
  381.      * has been set, this is the DCOPClient::mainClient().
  382.      * @return the DCOPClient of this object
  383.      * @since 3.1
  384.      */
  385.     DCOPClient* dcopClient() const;
  386.  
  387.     /**
  388.      * Sets a specific dcop client for this reference. Otherwise
  389.      * DCOPClient::mainClient() is used.
  390.      * @param client the new DCOPClient of this object
  391.      * @since 3.1
  392.      */
  393.     void setDCOPClient( DCOPClient *client );
  394.  
  395.     /**
  396.      * Flag for allowing entering the event loop if the call blocks too long.
  397.      * @p NoEventLoop disables entering the event loop.
  398.      * @p UseEventLoop allows entering the event loop while waiting for long
  399.      * blocking DCOP call, thus making the GUI repaint if needed, and possibly
  400.      * allowing also other code in the application to be executed.
  401.      * @see DCOPClient::call()
  402.      */
  403.     enum EventLoopFlag { NoEventLoop, UseEventLoop };
  404.     /**
  405.      * Calls the function @p fun on the object referenced by this reference.
  406.      * @param fun the name of the DCOP function. This can be either the
  407.      *            full function signature (e.g. "setName(QString)") or
  408.      *            only the function's name (e.g. "setName"). In the
  409.      *            latter case the exact signature will be guessed from
  410.      *            the arguments
  411.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  412.      *         when an error occurred.
  413.      * @see send()
  414.      * @see DCOPArg
  415.      * @since 3.1
  416.      */
  417.     DCOPReply call( const QCString& fun ) {
  418.     QByteArray data;
  419.     return callInternal( fun, "()", data );
  420.     }
  421.  
  422.     /**
  423.      * Like call(), with additional arguments allowing entering the event loop
  424.      * and specifying timeout.
  425.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  426.      *            the call blocks too long
  427.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  428.      * @param fun the name of the DCOP function. This can be either the
  429.      *            full function signature (e.g. "setName(QString)") or
  430.      *            only the function's name (e.g. "setName"). In the
  431.      *            latter case the exact signature will be guessed from
  432.      *            the arguments
  433.      * @since 3.2
  434.      */
  435.     DCOPReply callExt( const QCString& fun, EventLoopFlag useEventLoop=NoEventLoop,
  436.             int timeout=-1 ) {
  437.     QByteArray data;
  438.     return callInternal( fun, "()", data, useEventLoop, timeout );
  439.     }
  440.  
  441.     /**
  442.      * Calls the function @p fun on the object referenced by this reference.
  443.      * @param fun the name of the DCOP function. This can be either the
  444.      *            full function signature (e.g. "setName(QString)") or
  445.      *            only the function's name (e.g. "setName"). In the
  446.      *            latter case the exact signature will be guessed from
  447.      *            the arguments
  448.      * @param t1 the first argument of the function. This can be a
  449.      *           supported base type or a DCOPArg object.
  450.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  451.      *         when an error occurred.
  452.      * @see send()
  453.      * @see DCOPArg
  454.      * @since 3.1
  455.      */
  456.     template <class T1>
  457.     DCOPReply call( const QCString& fun, const T1& t1 ) {
  458.     QCString args;
  459.     args.sprintf( "(%s)",
  460.              dcopTypeName(t1) );
  461.     QByteArray data;
  462.     QDataStream ds( data, IO_WriteOnly );
  463.     ds << t1;
  464.     return callInternal( fun, args, data );
  465.     }
  466.  
  467.     /**
  468.      * Like call(), with additional arguments allowing entering the event loop
  469.      * and specifying timeout.
  470.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  471.      *            the call blocks too long
  472.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  473.      * @param fun the name of the DCOP function. This can be either the
  474.      *            full function signature (e.g. "setName(QString)") or
  475.      *            only the function's name (e.g. "setName"). In the
  476.      *            latter case the exact signature will be guessed from
  477.      *            the arguments
  478.      * @param t1 the first argument of the function. This can be a
  479.      *           supported base type or a DCOPArg object.
  480.      * @since 3.2
  481.      */
  482.     template <class T1>
  483.     DCOPReply callExt( const QCString& fun,
  484.             EventLoopFlag useEventLoop, int timeout,
  485.             const T1& t1) {
  486.     QCString args;
  487.     args.sprintf( "(%s)",
  488.              dcopTypeName(t1) );
  489.     QByteArray data;
  490.     QDataStream ds( data, IO_WriteOnly );
  491.     ds << t1;
  492.     return callInternal( fun, args, data, useEventLoop, timeout );
  493.     }
  494.  
  495.     /**
  496.      * Calls the function @p fun on the object referenced by this reference.
  497.      * @param fun the name of the DCOP function. This can be either the
  498.      *            full function signature (e.g. "setName(QString)") or
  499.      *            only the function's name (e.g. "setName"). In the
  500.      *            latter case the exact signature will be guessed from
  501.      *            the arguments
  502.      * @param t1 the first argument of the function. This can be a
  503.      *           supported base type or a DCOPArg object.
  504.      * @param t2 the second argument of the function. This can be a
  505.      *           supported base type or a DCOPArg object.
  506.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  507.      *         when an error occurred.
  508.      * @see send()
  509.      * @see DCOPArg
  510.      * @since 3.1
  511.      */
  512.     template <class T1, class T2>
  513.     DCOPReply call( const QCString& fun,
  514.             const T1& t1,
  515.             const T2& t2 ) {
  516.     QCString args;
  517.     args.sprintf( "(%s,%s)",
  518.              dcopTypeName(t1),
  519.              dcopTypeName(t2) );
  520.     QByteArray data;
  521.     QDataStream ds( data, IO_WriteOnly );
  522.     ds << t1 << t2;
  523.     return callInternal( fun, args, data );
  524.     }
  525.  
  526.     /**
  527.      * Like call(), with additional arguments allowing entering the event loop
  528.      * and specifying timeout.
  529.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  530.      *            the call blocks too long
  531.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  532.      * @param fun the name of the DCOP function. This can be either the
  533.      *            full function signature (e.g. "setName(QString)") or
  534.      *            only the function's name (e.g. "setName"). In the
  535.      *            latter case the exact signature will be guessed from
  536.      *            the arguments
  537.      * @param t1 the first argument of the function. This can be a
  538.      *           supported base type or a DCOPArg object.
  539.      * @param t2 the second argument of the function. This can be a
  540.      *           supported base type or a DCOPArg object.
  541.      * @since 3.2
  542.      */
  543.     template <class T1, class T2>
  544.     DCOPReply callExt( const QCString& fun,
  545.             EventLoopFlag useEventLoop, int timeout,
  546.             const T1& t1,
  547.             const T2& t2) {
  548.     QCString args;
  549.     args.sprintf( "(%s,%s)",
  550.              dcopTypeName(t1),
  551.              dcopTypeName(t2) );
  552.     QByteArray data;
  553.     QDataStream ds( data, IO_WriteOnly );
  554.     ds << t1 << t2;
  555.     return callInternal( fun, args, data, useEventLoop, timeout );
  556.     }
  557.  
  558.     /**
  559.      * Calls the function @p fun on the object referenced by this reference.
  560.      * @param fun the name of the DCOP function. This can be either the
  561.      *            full function signature (e.g. "setName(QString)") or
  562.      *            only the function's name (e.g. "setName"). In the
  563.      *            latter case the exact signature will be guessed from
  564.      *            the arguments
  565.      * @param t1 the first argument of the function. This can be a
  566.      *           supported base type or a DCOPArg object.
  567.      * @param t2 the second argument of the function. This can be a
  568.      *           supported base type or a DCOPArg object.
  569.      * @param t3 the third argument of the function. This can be a
  570.      *           supported base type or a DCOPArg object.
  571.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  572.      *         when an error occurred.
  573.      * @see send()
  574.      * @see DCOPArg
  575.      * @since 3.1
  576.      */
  577.     template <class T1, class T2, class T3>
  578.     DCOPReply call( const QCString& fun,
  579.             const T1& t1,
  580.             const T2& t2,
  581.             const T3& t3 ) {
  582.     QCString args;
  583.     args.sprintf( "(%s,%s,%s)",
  584.              dcopTypeName(t1),
  585.              dcopTypeName(t2),
  586.              dcopTypeName(t3) );
  587.     QByteArray data;
  588.     QDataStream ds( data, IO_WriteOnly );
  589.     ds << t1 << t2 << t3;
  590.     return callInternal( fun, args, data );
  591.     }
  592.  
  593.     /**
  594.      * Like call(), with additional arguments allowing entering the event loop
  595.      * and specifying timeout.
  596.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  597.      *            the call blocks too long
  598.      * @param fun the name of the DCOP function. This can be either the
  599.      *            full function signature (e.g. "setName(QString)") or
  600.      *            only the function's name (e.g. "setName"). In the
  601.      *            latter case the exact signature will be guessed from
  602.      *            the arguments
  603.      * @param t1 the first argument of the function. This can be a
  604.      *           supported base type or a DCOPArg object.
  605.      * @param t2 the second argument of the function. This can be a
  606.      *           supported base type or a DCOPArg object.
  607.      * @param t3 the third argument of the function. This can be a
  608.      *           supported base type or a DCOPArg object.
  609.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  610.      * @since 3.2
  611.      */
  612.     template <class T1, class T2, class T3>
  613.     DCOPReply callExt( const QCString& fun,
  614.             EventLoopFlag useEventLoop, int timeout,
  615.             const T1& t1,
  616.             const T2& t2,
  617.             const T3& t3) {
  618.     QCString args;
  619.     args.sprintf( "(%s,%s,%s)",
  620.              dcopTypeName(t1),
  621.              dcopTypeName(t2),
  622.              dcopTypeName(t3) );
  623.     QByteArray data;
  624.     QDataStream ds( data, IO_WriteOnly );
  625.     ds << t1 << t2 << t3;
  626.     return callInternal( fun, args, data, useEventLoop, timeout );
  627.     }
  628.  
  629.     /**
  630.      * Calls the function @p fun on the object referenced by this reference.
  631.      * @param fun the name of the DCOP function. This can be either the
  632.      *            full function signature (e.g. "setName(QString)") or
  633.      *            only the function's name (e.g. "setName"). In the
  634.      *            latter case the exact signature will be guessed from
  635.      *            the arguments
  636.      * @param t1 the first argument of the function. This can be a
  637.      *           supported base type or a DCOPArg object.
  638.      * @param t2 the second argument of the function. This can be a
  639.      *           supported base type or a DCOPArg object.
  640.      * @param t3 the third argument of the function. This can be a
  641.      *           supported base type or a DCOPArg object.
  642.      * @param t4 the fourth argument of the function. This can be a
  643.      *           supported base type or a DCOPArg object.
  644.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  645.      *         when an error occurred.
  646.      * @see send()
  647.      * @see DCOPArg
  648.      * @since 3.1
  649.      */
  650.     template <class T1,class T2,class T3,class T4>
  651.     DCOPReply call( const QCString& fun,
  652.             const T1& t1,
  653.             const T2& t2,
  654.             const T3& t3,
  655.             const T4& t4 ) {
  656.     QCString args;
  657.     args.sprintf( "(%s,%s,%s,%s)",
  658.              dcopTypeName(t1),
  659.              dcopTypeName(t2),
  660.              dcopTypeName(t3),
  661.              dcopTypeName(t4) );
  662.     QByteArray data;
  663.     QDataStream ds( data, IO_WriteOnly );
  664.     ds << t1 << t2 << t3 << t4;
  665.     return callInternal( fun, args, data );
  666.     }
  667.  
  668.     /**
  669.      * Like call(), with additional arguments allowing entering the event loop
  670.      * and specifying timeout.
  671.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  672.      *            the call blocks too long
  673.      * @param fun the name of the DCOP function. This can be either the
  674.      *            full function signature (e.g. "setName(QString)") or
  675.      *            only the function's name (e.g. "setName"). In the
  676.      *            latter case the exact signature will be guessed from
  677.      *            the arguments
  678.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  679.      * @param t1 the first argument of the function. This can be a
  680.      *           supported base type or a DCOPArg object.
  681.      * @param t2 the second argument of the function. This can be a
  682.      *           supported base type or a DCOPArg object.
  683.      * @param t3 the third argument of the function. This can be a
  684.      *           supported base type or a DCOPArg object.
  685.      * @param t4 the fourth argument of the function. This can be a
  686.      *           supported base type or a DCOPArg object.
  687.      * @since 3.2
  688.      */
  689.     template <class T1,class T2,class T3,class T4>
  690.     DCOPReply callExt( const QCString& fun,
  691.             EventLoopFlag useEventLoop, int timeout,
  692.             const T1& t1,
  693.             const T2& t2,
  694.             const T3& t3,
  695.             const T4& t4) {
  696.     QCString args;
  697.     args.sprintf( "(%s,%s,%s,%s)",
  698.              dcopTypeName(t1),
  699.              dcopTypeName(t2),
  700.              dcopTypeName(t3),
  701.              dcopTypeName(t4) );
  702.     QByteArray data;
  703.     QDataStream ds( data, IO_WriteOnly );
  704.     ds << t1 << t2 << t3 << t4;
  705.     return callInternal( fun, args, data, useEventLoop, timeout );
  706.     }
  707.  
  708.     /**
  709.      * Calls the function @p fun on the object referenced by this reference.
  710.      * @param fun the name of the DCOP function. This can be either the
  711.      *            full function signature (e.g. "setName(QString)") or
  712.      *            only the function's name (e.g. "setName"). In the
  713.      *            latter case the exact signature will be guessed from
  714.      *            the arguments
  715.      * @param t1 the first argument of the function. This can be a
  716.      *           supported base type or a DCOPArg object.
  717.      * @param t2 the second argument of the function. This can be a
  718.      *           supported base type or a DCOPArg object.
  719.      * @param t3 the third argument of the function. This can be a
  720.      *           supported base type or a DCOPArg object.
  721.      * @param t4 the fourth argument of the function. This can be a
  722.      *           supported base type or a DCOPArg object.
  723.      * @param t5 the fifth argument of the function. This can be a
  724.      *           supported base type or a DCOPArg object.
  725.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  726.      *         when an error occurred.
  727.      * @see send()
  728.      * @see DCOPArg
  729.      * @since 3.1
  730.      */
  731.     template <class T1,class T2,class T3,class T4,class T5>
  732.     DCOPReply call( const QCString& fun,
  733.             const T1& t1,
  734.             const T2& t2,
  735.             const T3& t3,
  736.             const T4& t4,
  737.             const T5& t5 ) {
  738.     QCString args;
  739.     args.sprintf( "(%s,%s,%s,%s,%s)",
  740.              dcopTypeName(t1),
  741.              dcopTypeName(t2),
  742.              dcopTypeName(t3),
  743.              dcopTypeName(t4),
  744.              dcopTypeName(t5) );
  745.     QByteArray data;
  746.     QDataStream ds( data, IO_WriteOnly );
  747.     ds << t1 << t2 << t3 << t4 << t5;
  748.     return callInternal( fun, args, data );
  749.     }
  750.  
  751.     /**
  752.      * Like call(), with additional arguments allowing entering the event loop
  753.      * and specifying timeout.
  754.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  755.      *            the call blocks too long
  756.      * @param fun the name of the DCOP function. This can be either the
  757.      *            full function signature (e.g. "setName(QString)") or
  758.      *            only the function's name (e.g. "setName"). In the
  759.      *            latter case the exact signature will be guessed from
  760.      *            the arguments
  761.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  762.      * @param t1 the first argument of the function. This can be a
  763.      *           supported base type or a DCOPArg object.
  764.      * @param t2 the second argument of the function. This can be a
  765.      *           supported base type or a DCOPArg object.
  766.      * @param t3 the third argument of the function. This can be a
  767.      *           supported base type or a DCOPArg object.
  768.      * @param t4 the fourth argument of the function. This can be a
  769.      *           supported base type or a DCOPArg object.
  770.      * @param t5 the fifth argument of the function. This can be a
  771.      *           supported base type or a DCOPArg object.
  772.      * @since 3.2
  773.      */
  774.     template <class T1,class T2,class T3,class T4,class T5>
  775.     DCOPReply callExt( const QCString& fun,
  776.             EventLoopFlag useEventLoop, int timeout,
  777.             const T1& t1,
  778.             const T2& t2,
  779.             const T3& t3,
  780.             const T4& t4,
  781.             const T5& t5 ) {
  782.     QCString args;
  783.     args.sprintf( "(%s,%s,%s,%s,%s)",
  784.              dcopTypeName(t1),
  785.              dcopTypeName(t2),
  786.              dcopTypeName(t3),
  787.              dcopTypeName(t4),
  788.              dcopTypeName(t5) );
  789.     QByteArray data;
  790.     QDataStream ds( data, IO_WriteOnly );
  791.     ds << t1 << t2 << t3 << t4 << t5;
  792.     return callInternal( fun, args, data, useEventLoop, timeout );
  793.     }
  794.  
  795.     /**
  796.      * Calls the function @p fun on the object referenced by this reference.
  797.      * @param fun the name of the DCOP function. This can be either the
  798.      *            full function signature (e.g. "setName(QString)") or
  799.      *            only the function's name (e.g. "setName"). In the
  800.      *            latter case the exact signature will be guessed from
  801.      *            the arguments
  802.      * @param t1 the first argument of the function. This can be a
  803.      *           supported base type or a DCOPArg object.
  804.      * @param t2 the second argument of the function. This can be a
  805.      *           supported base type or a DCOPArg object.
  806.      * @param t3 the third argument of the function. This can be a
  807.      *           supported base type or a DCOPArg object.
  808.      * @param t4 the fourth argument of the function. This can be a
  809.      *           supported base type or a DCOPArg object.
  810.      * @param t5 the fifth argument of the function. This can be a
  811.      *           supported base type or a DCOPArg object.
  812.      * @param t6 the sixth argument of the function. This can be a
  813.      *           supported base type or a DCOPArg object.
  814.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  815.      *         when an error occurred.
  816.      * @see send()
  817.      * @see DCOPArg
  818.      * @since 3.1
  819.      */
  820.     template <class T1,class T2,class T3,class T4,class T5,class T6>
  821.     DCOPReply call( const QCString& fun,
  822.             const T1& t1,
  823.             const T2& t2,
  824.             const T3& t3,
  825.             const T4& t4,
  826.             const T5& t5,
  827.             const T6& t6 ) {
  828.     QCString args;
  829.     args.sprintf( "(%s,%s,%s,%s,%s,%s)",
  830.              dcopTypeName(t1),
  831.              dcopTypeName(t2),
  832.              dcopTypeName(t3),
  833.              dcopTypeName(t4),
  834.              dcopTypeName(t5),
  835.              dcopTypeName(t6) );
  836.     QByteArray data;
  837.     QDataStream ds( data, IO_WriteOnly );
  838.     ds << t1 << t2 << t3 << t4 << t5 << t6;
  839.     return callInternal( fun, args, data );
  840.     }
  841.  
  842.     /**
  843.      * Like call(), with additional arguments allowing entering the event loop
  844.      * and specifying timeout.
  845.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  846.      *            the call blocks too long
  847.      * @param fun the name of the DCOP function. This can be either the
  848.      *            full function signature (e.g. "setName(QString)") or
  849.      *            only the function's name (e.g. "setName"). In the
  850.      *            latter case the exact signature will be guessed from
  851.      *            the arguments
  852.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  853.      * @param t1 the first argument of the function. This can be a
  854.      *           supported base type or a DCOPArg object.
  855.      * @param t2 the second argument of the function. This can be a
  856.      *           supported base type or a DCOPArg object.
  857.      * @param t3 the third argument of the function. This can be a
  858.      *           supported base type or a DCOPArg object.
  859.      * @param t4 the fourth argument of the function. This can be a
  860.      *           supported base type or a DCOPArg object.
  861.      * @param t5 the fifth argument of the function. This can be a
  862.      *           supported base type or a DCOPArg object.
  863.      * @param t6 the sixth argument of the function. This can be a
  864.      *           supported base type or a DCOPArg object.
  865.      * @since 3.2
  866.      */
  867.     template <class T1,class T2,class T3,class T4,class T5,class T6>
  868.     DCOPReply callExt( const QCString& fun,
  869.             EventLoopFlag useEventLoop, int timeout,
  870.             const T1& t1,
  871.             const T2& t2,
  872.             const T3& t3,
  873.             const T4& t4,
  874.             const T5& t5,
  875.             const T6& t6) {
  876.     QCString args;
  877.     args.sprintf( "(%s,%s,%s,%s,%s,%s)",
  878.              dcopTypeName(t1),
  879.              dcopTypeName(t2),
  880.              dcopTypeName(t3),
  881.              dcopTypeName(t4),
  882.              dcopTypeName(t5),
  883.              dcopTypeName(t6) );
  884.     QByteArray data;
  885.     QDataStream ds( data, IO_WriteOnly );
  886.     ds << t1 << t2 << t3 << t4 << t5 << t6;
  887.     return callInternal( fun, args, data, useEventLoop, timeout );
  888.     }
  889.     /**
  890.      * Calls the function @p fun on the object referenced by this reference.
  891.      * @param fun the name of the DCOP function. This can be either the
  892.      *            full function signature (e.g. "setName(QString)") or
  893.      *            only the function's name (e.g. "setName"). In the
  894.      *            latter case the exact signature will be guessed from
  895.      *            the arguments
  896.      * @param t1 the first argument of the function. This can be a
  897.      *           supported base type or a DCOPArg object.
  898.      * @param t2 the second argument of the function. This can be a
  899.      *           supported base type or a DCOPArg object.
  900.      * @param t3 the third argument of the function. This can be a
  901.      *           supported base type or a DCOPArg object.
  902.      * @param t4 the fourth argument of the function. This can be a
  903.      *           supported base type or a DCOPArg object.
  904.      * @param t5 the fifth argument of the function. This can be a
  905.      *           supported base type or a DCOPArg object.
  906.      * @param t6 the sixth argument of the function. This can be a
  907.      *           supported base type or a DCOPArg object.
  908.      * @param t7 the seventh argument of the function. This can be a
  909.      *           supported base type or a DCOPArg object.
  910.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  911.      *         when an error occurred.
  912.      * @see send()
  913.      * @see DCOPArg
  914.      * @since 3.1
  915.      */
  916.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7>
  917.     DCOPReply call( const QCString& fun,
  918.             const T1& t1,
  919.             const T2& t2,
  920.             const T3& t3,
  921.             const T4& t4,
  922.             const T5& t5,
  923.             const T6& t6,
  924.             const T7& t7 ) {
  925.     QCString args;
  926.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s)",
  927.              dcopTypeName(t1),
  928.              dcopTypeName(t2),
  929.              dcopTypeName(t3),
  930.              dcopTypeName(t4),
  931.              dcopTypeName(t5),
  932.              dcopTypeName(t6),
  933.              dcopTypeName(t7) );
  934.     QByteArray data;
  935.     QDataStream ds( data, IO_WriteOnly );
  936.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7;
  937.     return callInternal( fun, args, data );
  938.     }
  939.  
  940.     /**
  941.      * Like call(), with additional arguments allowing entering the event loop
  942.      * and specifying timeout.
  943.      * @param fun the name of the DCOP function. This can be either the
  944.      *            full function signature (e.g. "setName(QString)") or
  945.      *            only the function's name (e.g. "setName"). In the
  946.      *            latter case the exact signature will be guessed from
  947.      *            the arguments
  948.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  949.      *            the call blocks too long
  950.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  951.      * @param t1 the first argument of the function. This can be a
  952.      *           supported base type or a DCOPArg object.
  953.      * @param t2 the second argument of the function. This can be a
  954.      *           supported base type or a DCOPArg object.
  955.      * @param t3 the third argument of the function. This can be a
  956.      *           supported base type or a DCOPArg object.
  957.      * @param t4 the fourth argument of the function. This can be a
  958.      *           supported base type or a DCOPArg object.
  959.      * @param t5 the fifth argument of the function. This can be a
  960.      *           supported base type or a DCOPArg object.
  961.      * @param t6 the sixth argument of the function. This can be a
  962.      *           supported base type or a DCOPArg object.
  963.      * @param t7 the seventh argument of the function. This can be a
  964.      *           supported base type or a DCOPArg object.
  965.      * @since 3.2
  966.      */
  967.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7>
  968.     DCOPReply callExt( const QCString& fun,
  969.             EventLoopFlag useEventLoop, int timeout,
  970.             const T1& t1,
  971.             const T2& t2,
  972.             const T3& t3,
  973.             const T4& t4,
  974.             const T5& t5,
  975.             const T6& t6,
  976.             const T7& t7) {
  977.     QCString args;
  978.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s)",
  979.              dcopTypeName(t1),
  980.              dcopTypeName(t2),
  981.              dcopTypeName(t3),
  982.              dcopTypeName(t4),
  983.              dcopTypeName(t5),
  984.              dcopTypeName(t6),
  985.              dcopTypeName(t7) );
  986.     QByteArray data;
  987.     QDataStream ds( data, IO_WriteOnly );
  988.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7;
  989.     return callInternal( fun, args, data, useEventLoop, timeout );
  990.     }
  991.  
  992.     /**
  993.      * Calls the function @p fun on the object referenced by this reference.
  994.      * @param fun the name of the DCOP function. This can be either the
  995.      *            full function signature (e.g. "setName(QString)") or
  996.      *            only the function's name (e.g. "setName"). In the
  997.      *            latter case the exact signature will be guessed from
  998.      *            the arguments
  999.      * @param t1 the first argument of the function. This can be a
  1000.      *           supported base type or a DCOPArg object.
  1001.      * @param t2 the second argument of the function. This can be a
  1002.      *           supported base type or a DCOPArg object.
  1003.      * @param t3 the third argument of the function. This can be a
  1004.      *           supported base type or a DCOPArg object.
  1005.      * @param t4 the fourth argument of the function. This can be a
  1006.      *           supported base type or a DCOPArg object.
  1007.      * @param t5 the fifth argument of the function. This can be a
  1008.      *           supported base type or a DCOPArg object.
  1009.      * @param t6 the sixth argument of the function. This can be a
  1010.      *           supported base type or a DCOPArg object.
  1011.      * @param t7 the seventh argument of the function. This can be a
  1012.      *           supported base type or a DCOPArg object.
  1013.      * @param t8 the eigth argument of the function. This can be a
  1014.      *           supported base type or a DCOPArg object.
  1015.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1016.      *         when an error occurred.
  1017.      * @see send()
  1018.      * @see DCOPArg
  1019.      * @since 3.1
  1020.      */
  1021.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
  1022.     DCOPReply call( const QCString& fun,
  1023.             const T1& t1,
  1024.             const T2& t2,
  1025.             const T3& t3,
  1026.             const T4& t4,
  1027.             const T5& t5,
  1028.             const T6& t6,
  1029.             const T7& t7,
  1030.             const T8& t8 ) {
  1031.     QCString args;
  1032.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s,%s)",
  1033.              dcopTypeName(t1),
  1034.              dcopTypeName(t2),
  1035.              dcopTypeName(t3),
  1036.              dcopTypeName(t4),
  1037.              dcopTypeName(t5),
  1038.              dcopTypeName(t6),
  1039.              dcopTypeName(t7),
  1040.              dcopTypeName(t8) );
  1041.     QByteArray data;
  1042.     QDataStream ds( data, IO_WriteOnly );
  1043.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7 << t8;
  1044.     return callInternal( fun, args, data );
  1045.     }
  1046.  
  1047.     /**
  1048.      * Like call(), with additional arguments allowing entering the event loop
  1049.      * and specifying timeout.
  1050.      * @param useEventLoop if UseEventLoop, the event loop will be started when
  1051.      *            the call blocks too long
  1052.      * @param timeout timeout for the call in miliseconds, or -1 for no timeout
  1053.      * @param t1 the first argument of the function. This can be a
  1054.      *           supported base type or a DCOPArg object.
  1055.      * @param t2 the second argument of the function. This can be a
  1056.      *           supported base type or a DCOPArg object.
  1057.      * @param t3 the third argument of the function. This can be a
  1058.      *           supported base type or a DCOPArg object.
  1059.      * @param t4 the fourth argument of the function. This can be a
  1060.      *           supported base type or a DCOPArg object.
  1061.      * @param t5 the fifth argument of the function. This can be a
  1062.      *           supported base type or a DCOPArg object.
  1063.      * @param t6 the sixth argument of the function. This can be a
  1064.      *           supported base type or a DCOPArg object.
  1065.      * @param t7 the seventh argument of the function. This can be a
  1066.      *           supported base type or a DCOPArg object.
  1067.      * @param t8 the eigth argument of the function. This can be a
  1068.      *           supported base type or a DCOPArg object.
  1069.      * @param fun the name of the DCOP function. This can be either the
  1070.      *            full function signature (e.g. "setName(QString)") or
  1071.      *            only the function's name (e.g. "setName"). In the
  1072.      *            latter case the exact signature will be guessed from
  1073.      *            the arguments
  1074.      * @since 3.2
  1075.      */
  1076.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
  1077.     DCOPReply callExt( const QCString& fun,
  1078.             EventLoopFlag useEventLoop, int timeout,
  1079.             const T1& t1,
  1080.             const T2& t2,
  1081.             const T3& t3,
  1082.             const T4& t4,
  1083.             const T5& t5,
  1084.             const T6& t6,
  1085.             const T7& t7,
  1086.             const T8& t8) {
  1087.     QCString args;
  1088.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s,%s)",
  1089.              dcopTypeName(t1),
  1090.              dcopTypeName(t2),
  1091.              dcopTypeName(t3),
  1092.              dcopTypeName(t4),
  1093.              dcopTypeName(t5),
  1094.              dcopTypeName(t6),
  1095.              dcopTypeName(t7),
  1096.              dcopTypeName(t8) );
  1097.     QByteArray data;
  1098.     QDataStream ds( data, IO_WriteOnly );
  1099.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7 << t8;
  1100.     return callInternal( fun, args, data, useEventLoop, timeout );
  1101.     }
  1102.  
  1103.     /**
  1104.      * Calls the function @p fun on the object referenced by this reference.
  1105.      * Unlike call() this method does not expect a return value.
  1106.      * @param fun the name of the DCOP function. This can be either the
  1107.      *            full function signature (e.g. "setName(QString)") or
  1108.      *            only the function's name (e.g. "setName"). In the
  1109.      *            latter case the exact signature will be guessed from
  1110.      *            the arguments
  1111.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1112.      *         when an error occurred.
  1113.      * @see call()
  1114.      * @since 3.1
  1115.      */
  1116.     bool send( const QCString& fun ) {
  1117.     QByteArray data;
  1118.     return sendInternal( fun, "()", data );
  1119.     }
  1120.  
  1121.     /**
  1122.      * Calls the function @p fun on the object referenced by this reference.
  1123.      * Unlike call() this method does not expect a return value.
  1124.      * @param fun the name of the DCOP function. This can be either the
  1125.      *            full function signature (e.g. "setName(QString)") or
  1126.      *            only the function's name (e.g. "setName"). In the
  1127.      *            latter case the exact signature will be guessed from
  1128.      *            the arguments
  1129.      * @param t1 the first argument of the function. This can be a
  1130.      *           supported base type or a DCOPArg object.
  1131.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1132.      *         when an error occurred.
  1133.      * @see call()
  1134.      * @see DCOPArg
  1135.      * @since 3.1
  1136.      */
  1137.     template <class T1>
  1138.     bool send( const QCString& fun, const T1& t1 ) {
  1139.     QCString args;
  1140.     args.sprintf( "(%s)",
  1141.              dcopTypeName(t1) );
  1142.     QByteArray data;
  1143.     QDataStream ds( data, IO_WriteOnly );
  1144.     ds << t1;
  1145.     return sendInternal( fun, args, data );
  1146.     }
  1147.     /**
  1148.      * Calls the function @p fun on the object referenced by this reference.
  1149.      * Unlike call() this method does not expect a return value.
  1150.      * @param fun the name of the DCOP function. This can be either the
  1151.      *            full function signature (e.g. "setName(QString)") or
  1152.      *            only the function's name (e.g. "setName"). In the
  1153.      *            latter case the exact signature will be guessed from
  1154.      *            the arguments
  1155.      * @param t1 the first argument of the function. This can be a
  1156.      *           supported base type or a DCOPArg object.
  1157.      * @param t2 the second argument of the function. This can be a
  1158.      *           supported base type or a DCOPArg object.
  1159.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1160.      *         when an error occurred.
  1161.      * @see call()
  1162.      * @see DCOPArg
  1163.      * @since 3.1
  1164.      */
  1165.     template <class T1, class T2>
  1166.     bool send( const QCString& fun,
  1167.             const T1& t1,
  1168.             const T2& t2 ) {
  1169.     QCString args;
  1170.     args.sprintf( "(%s,%s)",
  1171.              dcopTypeName(t1),
  1172.              dcopTypeName(t2) );
  1173.     QByteArray data;
  1174.     QDataStream ds( data, IO_WriteOnly );
  1175.     ds << t1 << t2;
  1176.     return sendInternal( fun, args, data );
  1177.     }
  1178.     /**
  1179.      * Calls the function @p fun on the object referenced by this reference.
  1180.      * Unlike call() this method does not expect a return value.
  1181.      * @param fun the name of the DCOP function. This can be either the
  1182.      *            full function signature (e.g. "setName(QString)") or
  1183.      *            only the function's name (e.g. "setName"). In the
  1184.      *            latter case the exact signature will be guessed from
  1185.      *            the arguments
  1186.      * @param t1 the first argument of the function. This can be a
  1187.      *           supported base type or a DCOPArg object.
  1188.      * @param t2 the second argument of the function. This can be a
  1189.      *           supported base type or a DCOPArg object.
  1190.      * @param t3 the third argument of the function. This can be a
  1191.      *           supported base type or a DCOPArg object.
  1192.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1193.      *         when an error occurred.
  1194.      * @see call()
  1195.      * @see DCOPArg
  1196.      * @since 3.1
  1197.      */
  1198.     template <class T1, class T2, class T3>
  1199.     bool send( const QCString& fun,
  1200.             const T1& t1,
  1201.             const T2& t2,
  1202.             const T3& t3 ) {
  1203.     QCString args;
  1204.     args.sprintf( "(%s,%s,%s)",
  1205.              dcopTypeName(t1),
  1206.              dcopTypeName(t2),
  1207.              dcopTypeName(t3) );
  1208.     QByteArray data;
  1209.     QDataStream ds( data, IO_WriteOnly );
  1210.     ds << t1 << t2 << t3;
  1211.     return sendInternal( fun, args, data );
  1212.     }
  1213.     /**
  1214.      * Calls the function @p fun on the object referenced by this reference.
  1215.      * Unlike call() this method does not expect a return value.
  1216.      * @param fun the name of the DCOP function. This can be either the
  1217.      *            full function signature (e.g. "setName(QString)") or
  1218.      *            only the function's name (e.g. "setName"). In the
  1219.      *            latter case the exact signature will be guessed from
  1220.      *            the arguments
  1221.      * @param t1 the first argument of the function. This can be a
  1222.      *           supported base type or a DCOPArg object.
  1223.      * @param t2 the second argument of the function. This can be a
  1224.      *           supported base type or a DCOPArg object.
  1225.      * @param t3 the third argument of the function. This can be a
  1226.      *           supported base type or a DCOPArg object.
  1227.      * @param t4 the fourth argument of the function. This can be a
  1228.      *           supported base type or a DCOPArg object.
  1229.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1230.      *         when an error occurred.
  1231.      * @see call()
  1232.      * @see DCOPArg
  1233.      * @since 3.1
  1234.      */
  1235.     template <class T1,class T2,class T3,class T4>
  1236.     bool send( const QCString& fun,
  1237.             const T1& t1,
  1238.             const T2& t2,
  1239.             const T3& t3,
  1240.             const T4& t4 ) {
  1241.     QCString args;
  1242.     args.sprintf( "(%s,%s,%s,%s)",
  1243.              dcopTypeName(t1),
  1244.              dcopTypeName(t2),
  1245.              dcopTypeName(t3),
  1246.              dcopTypeName(t4) );
  1247.     QByteArray data;
  1248.     QDataStream ds( data, IO_WriteOnly );
  1249.     ds << t1 << t2 << t3 << t4;
  1250.     return sendInternal( fun, args, data );
  1251.     }
  1252.     /**
  1253.      * Calls the function @p fun on the object referenced by this reference.
  1254.      * Unlike call() this method does not expect a return value.
  1255.      * @param fun the name of the DCOP function. This can be either the
  1256.      *            full function signature (e.g. "setName(QString)") or
  1257.      *            only the function's name (e.g. "setName"). In the
  1258.      *            latter case the exact signature will be guessed from
  1259.      *            the arguments
  1260.      * @param t1 the first argument of the function. This can be a
  1261.      *           supported base type or a DCOPArg object.
  1262.      * @param t2 the second argument of the function. This can be a
  1263.      *           supported base type or a DCOPArg object.
  1264.      * @param t3 the third argument of the function. This can be a
  1265.      *           supported base type or a DCOPArg object.
  1266.      * @param t4 the fourth argument of the function. This can be a
  1267.      *           supported base type or a DCOPArg object.
  1268.      * @param t5 the fifth argument of the function. This can be a
  1269.      *           supported base type or a DCOPArg object.
  1270.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1271.      *         when an error occurred.
  1272.      * @see call()
  1273.      * @see DCOPArg
  1274.      * @since 3.1
  1275.      */
  1276.     template <class T1,class T2,class T3,class T4,class T5>
  1277.     bool send( const QCString& fun,
  1278.             const T1& t1,
  1279.             const T2& t2,
  1280.             const T3& t3,
  1281.             const T4& t4,
  1282.             const T5& t5 ) {
  1283.     QCString args;
  1284.     args.sprintf( "(%s,%s,%s,%s,%s)",
  1285.              dcopTypeName(t1),
  1286.              dcopTypeName(t2),
  1287.              dcopTypeName(t3),
  1288.              dcopTypeName(t4),
  1289.              dcopTypeName(t5) );
  1290.     QByteArray data;
  1291.     QDataStream ds( data, IO_WriteOnly );
  1292.     ds << t1 << t2 << t3 << t4 << t5;
  1293.     return sendInternal( fun, args, data );
  1294.     }
  1295.     /**
  1296.      * Calls the function @p fun on the object referenced by this reference.
  1297.      * Unlike call() this method does not expect a return value.
  1298.      * @param fun the name of the DCOP function. This can be either the
  1299.      *            full function signature (e.g. "setName(QString)") or
  1300.      *            only the function's name (e.g. "setName"). In the
  1301.      *            latter case the exact signature will be guessed from
  1302.      *            the arguments
  1303.      * @param t1 the first argument of the function. This can be a
  1304.      *           supported base type or a DCOPArg object.
  1305.      * @param t2 the second argument of the function. This can be a
  1306.      *           supported base type or a DCOPArg object.
  1307.      * @param t3 the third argument of the function. This can be a
  1308.      *           supported base type or a DCOPArg object.
  1309.      * @param t4 the fourth argument of the function. This can be a
  1310.      *           supported base type or a DCOPArg object.
  1311.      * @param t5 the fifth argument of the function. This can be a
  1312.      *           supported base type or a DCOPArg object.
  1313.      * @param t6 the sixth argument of the function. This can be a
  1314.      *           supported base type or a DCOPArg object.
  1315.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1316.      *         when an error occurred.
  1317.      * @see call()
  1318.      * @see DCOPArg
  1319.      * @since 3.1
  1320.      */
  1321.     template <class T1,class T2,class T3,class T4,class T5,class T6>
  1322.     bool send( const QCString& fun,
  1323.             const T1& t1,
  1324.             const T2& t2,
  1325.             const T3& t3,
  1326.             const T4& t4,
  1327.             const T5& t5,
  1328.             const T6& t6 ) {
  1329.     QCString args;
  1330.     args.sprintf( "(%s,%s,%s,%s,%s,%s)",
  1331.              dcopTypeName(t1),
  1332.              dcopTypeName(t2),
  1333.              dcopTypeName(t3),
  1334.              dcopTypeName(t4),
  1335.              dcopTypeName(t5),
  1336.              dcopTypeName(t6) );
  1337.     QByteArray data;
  1338.     QDataStream ds( data, IO_WriteOnly );
  1339.     ds << t1 << t2 << t3 << t4 << t5 << t6;
  1340.     return sendInternal( fun, args, data );
  1341.     }
  1342.     /**
  1343.      * Calls the function @p fun on the object referenced by this reference.
  1344.      * Unlike call() this method does not expect a return value.
  1345.      * @param fun the name of the DCOP function. This can be either the
  1346.      *            full function signature (e.g. "setName(QString)") or
  1347.      *            only the function's name (e.g. "setName"). In the
  1348.      *            latter case the exact signature will be guessed from
  1349.      *            the arguments
  1350.      * @param t1 the first argument of the function. This can be a
  1351.      *           supported base type or a DCOPArg object.
  1352.      * @param t2 the second argument of the function. This can be a
  1353.      *           supported base type or a DCOPArg object.
  1354.      * @param t3 the third argument of the function. This can be a
  1355.      *           supported base type or a DCOPArg object.
  1356.      * @param t4 the fourth argument of the function. This can be a
  1357.      *           supported base type or a DCOPArg object.
  1358.      * @param t5 the fifth argument of the function. This can be a
  1359.      *           supported base type or a DCOPArg object.
  1360.      * @param t6 the sixth argument of the function. This can be a
  1361.      *           supported base type or a DCOPArg object.
  1362.      * @param t7 the seventh argument of the function. This can be a
  1363.      *           supported base type or a DCOPArg object.
  1364.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1365.      *         when an error occurred.
  1366.      * @see call()
  1367.      * @see DCOPArg
  1368.      * @since 3.1
  1369.      */
  1370.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7>
  1371.     bool send( const QCString& fun,
  1372.             const T1& t1,
  1373.             const T2& t2,
  1374.             const T3& t3,
  1375.             const T4& t4,
  1376.             const T5& t5,
  1377.             const T6& t6,
  1378.             const T7& t7 ) {
  1379.     QCString args;
  1380.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s)",
  1381.              dcopTypeName(t1),
  1382.              dcopTypeName(t2),
  1383.              dcopTypeName(t3),
  1384.              dcopTypeName(t4),
  1385.              dcopTypeName(t5),
  1386.              dcopTypeName(t6),
  1387.              dcopTypeName(t7) );
  1388.     QByteArray data;
  1389.     QDataStream ds( data, IO_WriteOnly );
  1390.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7;
  1391.     return sendInternal( fun, args, data );
  1392.     }
  1393.     /**
  1394.      * Calls the function @p fun on the object referenced by this reference.
  1395.      * Unlike call() this method does not expect a return value.
  1396.      * @param fun the name of the DCOP function. This can be either the
  1397.      *            full function signature (e.g. "setName(QString)") or
  1398.      *            only the function's name (e.g. "setName"). In the
  1399.      *            latter case the exact signature will be guessed from
  1400.      *            the arguments
  1401.      * @param t1 the first argument of the function. This can be a
  1402.      *           supported base type or a DCOPArg object.
  1403.      * @param t2 the second argument of the function. This can be a
  1404.      *           supported base type or a DCOPArg object.
  1405.      * @param t3 the third argument of the function. This can be a
  1406.      *           supported base type or a DCOPArg object.
  1407.      * @param t4 the fourth argument of the function. This can be a
  1408.      *           supported base type or a DCOPArg object.
  1409.      * @param t5 the fifth argument of the function. This can be a
  1410.      *           supported base type or a DCOPArg object.
  1411.      * @param t6 the sixth argument of the function. This can be a
  1412.      *           supported base type or a DCOPArg object.
  1413.      * @param t7 the seventh argument of the function. This can be a
  1414.      *           supported base type or a DCOPArg object.
  1415.      * @param t8 the eigth argument of the function. This can be a
  1416.      *           supported base type or a DCOPArg object.
  1417.      * @return the DCOPReply object. Is invalid ( DCOPReply::isValid())
  1418.      *         when an error occurred.
  1419.      * @see call()
  1420.      * @see DCOPArg
  1421.      * @since 3.1
  1422.      */
  1423.     template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
  1424.     bool send( const QCString& fun,
  1425.             const T1& t1,
  1426.             const T2& t2,
  1427.             const T3& t3,
  1428.             const T4& t4,
  1429.             const T5& t5,
  1430.             const T6& t6,
  1431.             const T7& t7,
  1432.             const T8& t8 ) {
  1433.     QCString args;
  1434.     args.sprintf( "(%s,%s,%s,%s,%s,%s,%s,%s)",
  1435.              dcopTypeName(t1),
  1436.              dcopTypeName(t2),
  1437.              dcopTypeName(t3),
  1438.              dcopTypeName(t4),
  1439.              dcopTypeName(t5),
  1440.              dcopTypeName(t6),
  1441.              dcopTypeName(t7),
  1442.              dcopTypeName(t8) );
  1443.     QByteArray data;
  1444.     QDataStream ds( data, IO_WriteOnly );
  1445.     ds << t1 << t2 << t3 << t4 << t5 << t6 << t7 << t8;
  1446.     return sendInternal( fun, args, data );
  1447.     }
  1448.  
  1449.  
  1450.  
  1451. private:
  1452.     DCOPReply callInternal( const QCString& fun, const QCString& args, const QByteArray& data,
  1453.                 EventLoopFlag useEventLoop, int timeout );
  1454.     DCOPReply callInternal( const QCString& fun, const QCString& args, const QByteArray& data );
  1455.     bool sendInternal( const QCString& fun, const QCString& args, const QByteArray& data );
  1456.  
  1457.     QCString m_app;
  1458.     QCString m_obj;
  1459.     QCString m_type;
  1460.  
  1461.     class DCOPRefPrivate;
  1462.     DCOPRefPrivate *d;
  1463. };
  1464.  
  1465. /**
  1466.  * Writes the reference (NOT the object itself) to the stream.
  1467.  */
  1468. DCOP_EXPORT QDataStream& operator<<( QDataStream&, const DCOPRef& ref );
  1469. /**
  1470.  * Reads a reference from the stream.
  1471.  */
  1472. DCOP_EXPORT QDataStream& operator>>( QDataStream&, DCOPRef& ref );
  1473.  
  1474. #endif
  1475.